﻿using CPPEI.ETL.DataServiceInterface;
using CPPEI.WebApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using ENT = CPPEI.ETL.Domain.Entities;
using MOD = CPPEI.ETL.Domain.Models;
using SER = CPPEI.ETL.Domain.Services;

namespace CPPEI.ETL.WebApi
{
    [CPPEI.WebApi.AuthPostAction("ETL", "DeleteDataTable", "1.0")]
    public class DeleteDataTableAction : BaseAction<DeleteDataTableParams, DeleteDataTableResult>
    {
        protected override ActionResult<DeleteDataTableResult> OnExecute(ActionContext context, 
            SysParameters sysParameters,
            DeleteDataTableParams opParams)
        {
            SER.DeleteService service = new SER.DeleteService();
            ServiceResult serResult = service.DeleteDataTable(context.UserId, opParams.TableId);

            if(serResult.IsSuccess)
            {
                DeleteDataTableResult result = new DeleteDataTableResult();

                return new ActionResult<DeleteDataTableResult>(result);
            }
            else
            {
                return new ActionResult<DeleteDataTableResult>(serResult.IsSuccess, serResult.ErrorCode, serResult.Message, null);
            }
        }
    }

    public class DeleteDataTableParams
    {
        [Parameter]
        public Guid TableId { get; set; }
    }

    public class DeleteDataTableResult
    {
    }
}
